package com.yhm.testSpringMvc.Thread;

public class InnerClass {

        boolean isSubExec = true;

        public synchronized void sub(int i) {
            while (isSubExec == false) {
                try {
                    this.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (isSubExec == true) {
                for (int j = 0; j < 10; j++) {
                    System.out.println("子线程第" + i + "次循环" + j + "");
                }
            }
            isSubExec = false;
            this.notify();
        }

        public synchronized void main(int i) {
            while (isSubExec == true) {
                try {
                    this.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (isSubExec == false) {
                for (int j = 0; j < 100; j++) {
                    System.out.println("主main线程第" + i + "次循环" + j + "");
                }
            }
            isSubExec = true;
            this.notify();

        }
    }